﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CardLib;

namespace Durak_Game
{
    public partial class CardBox : UserControl
    {
        public delegate void CardBoxClicked(object sender, EventArgs e); // remembers the functions which have to executed
        public event CardBoxClicked cardBoxClicked; 
        public CardBox()
        {
            InitializeComponent();
            
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }
        private Card card;

        
     

        public void setCard(CardSuits suit, CardValues values)
        {

            this.card = new CardLib.Card(suit, values);
            card.Flip();
            pictureBox1.Image = card.FacingImage;
            
            
        }
        public void setCard(Card card) 
        {
            this.card = card;
            pictureBox1.Image = card.BackImage;
        }
        public void flipCard()
        {
            this.card.Flip();
            pictureBox1.Image = card.FaceImage;
        }
        public String getName()
        {
            return card.TextValue;
        }

        public void setCardClickable()
        {
            pictureBox1.Cursor = Cursors.Hand;
        }

        public Card getCard()
        {
            return this.card;
        }

        private void pictureBox1_Click_1(object sender, EventArgs e)
        {
            OnMyClickEvent(sender, e);
            

        }

        public void OnMyClickEvent(object sender, EventArgs e)
        {
            if (cardBoxClicked != null)
                cardBoxClicked(sender, e);//execute event
        }   

    }
}
